From: kaf24@labyrinth.cl.cam.ac.uk Date: Fri, 6 Dec 2002 11:40:56 +0000 (+0000) Subject: bitkeeper revision 1.7.1.6 (3df08cc8US1aforRcF-D7KIyM9F8Bw) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~19117^2~3 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=898bb9837e46faf85ee4ff4f6cd0c18379849824;p=xen.git bitkeeper revision 1.7.1.6 (3df08cc8US1aforRcF-D7KIyM9F8Bw) traps.c, setup.c, i387.c: Fix floating-point ctxt-switch code --- diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 825b553426..24128f27c5 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -1,4 +1,5 @@ akw27@boulderdash.cl.cam.ac.uk +kaf24@labyrinth.cl.cam.ac.uk kaf24@plym.cl.cam.ac.uk kaf24@striker.cl.cam.ac.uk smh22@boulderdash.cl.cam.ac.uk diff --git a/xen-2.4.16/arch/i386/i387.c b/xen-2.4.16/arch/i386/i387.c index dc94cc1dad..fe34ff16f5 100644 --- a/xen-2.4.16/arch/i386/i387.c +++ b/xen-2.4.16/arch/i386/i387.c @@ -22,20 +22,26 @@ void init_fpu(void) static inline void __save_init_fpu( struct task_struct *tsk ) { - if ( cpu_has_fxsr ) { - asm volatile( "fxsave %0 ; fnclex" - : "=m" (tsk->thread.i387.fxsave) ); - } else { - asm volatile( "fnsave %0 ; fwait" - : "=m" (tsk->thread.i387.fsave) ); - } - tsk->flags &= ~PF_USEDFPU; + if ( cpu_has_fxsr ) { + asm volatile( "fxsave %0 ; fnclex" + : "=m" (tsk->thread.i387.fxsave) ); + } else { + asm volatile( "fnsave %0 ; fwait" + : "=m" (tsk->thread.i387.fsave) ); + } + tsk->flags &= ~PF_USEDFPU; } void save_init_fpu( struct task_struct *tsk ) { - __save_init_fpu(tsk); - stts(); + /* + * The guest OS may have set the 'virtual STTS' flag. + * This causes us to set the real flag, so we'll need + * to temporarily clear it while saving f-p state. + */ + if ( tsk->flags & PF_GUEST_STTS ) clts(); + __save_init_fpu(tsk); + stts(); } void restore_fpu( struct task_struct *tsk ) diff --git a/xen-2.4.16/arch/i386/setup.c b/xen-2.4.16/arch/i386/setup.c index f9163148ed..3cb11f6b05 100644 --- a/xen-2.4.16/arch/i386/setup.c +++ b/xen-2.4.16/arch/i386/setup.c @@ -193,6 +193,9 @@ void __init cpu_init(void) /* No nested task. */ __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl"); + /* Ensure FPU gets initialised for each domain. */ + stts(); + /* Set up and load the per-CPU TSS and LDT. */ t->ss0 = __HYPERVISOR_DS; t->esp0 = current->thread.esp0; diff --git a/xen-2.4.16/arch/i386/traps.c b/xen-2.4.16/arch/i386/traps.c index e84690ad1a..6fd88f35f4 100644 --- a/xen-2.4.16/arch/i386/traps.c +++ b/xen-2.4.16/arch/i386/traps.c @@ -362,7 +362,8 @@ asmlinkage void do_nmi(struct pt_regs * regs, long error_code) asmlinkage void math_state_restore(struct pt_regs *regs, long error_code) { - __asm__ __volatile__("clts"); + /* Prevent recursion. */ + clts(); if ( !(current->flags & PF_USEDFPU) ) {